
# todo: ==================== 业务数据首日（第一次）同步 ====================

# ======================================================================
#                      todo： 1.订单表：order_info（新增和变化，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/order_info/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  total_amount,
  order_status,
  user_id,
  payment_way,
  delivery_address,
  out_trade_no,
  create_time,
  operate_time,
  expire_time,
  tracking_no,
  province_id,
  activity_reduce_amount,
  coupon_reduce_amount,
  original_total_amount,
  feight_fee,
  feight_fee_reduce
FROM order_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#               todo： 2.优惠券领用表：coupon_use（新增和变化，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/coupon_use/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  coupon_id,
  user_id,
  order_id,
  coupon_status,
  get_time,
  using_time,
  used_time,
  expire_time
FROM coupon_use
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#               todo： 3.用户表：user_info（新增和变化，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/user_info/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  login_name,
  nick_name,
  name,
  phone_num,
  email,
  user_level,
  birthday,
  gender,
  create_time,
  operate_time
FROM user_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#               todo： 4.支付信息表：payment_info（新增和变化，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/payment_info/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  out_trade_no,
  order_id,
  user_id,
  payment_type,
  trade_no,
  total_amount,
  subject,
  payment_status,
  create_time,
  callback_time
FROM payment_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#               todo： 5.退款信息表：refund_payment（新增和变化，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/refund_payment/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  out_trade_no,
  order_id,
  sku_id,
  payment_type,
  trade_no,
  total_amount,
  subject,
  refund_status,
  create_time,
  callback_time
FROM refund_payment
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'

